//
//  YZSickerMessageScrollView.m
//  患者信息界面（代码）
//
//  Created by Yip-Jun on 16/5/9.
//  Copyright © 2016年 YIPWJ. All rights reserved.
//

#import "YZSickerMessageScrollView.h"
#import "YZSickerMessageView.h"
#import "YZDoctorConditionView.h"
#import "YZSickDetailsView.h"
#import "Masonry.h"

@interface YZSickerMessageScrollView ()

@property (nonatomic, strong) UIView *testview;

@property (nonatomic, strong) YZSickerMessageView *sickerView;
@property (nonatomic, strong) YZDoctorConditionView *doctorView;
@property (nonatomic, strong) YZSickDetailsView *sickView;

@property (nonatomic, strong) MASConstraint *oldConstraint;

@end
@implementation YZSickerMessageScrollView

+ (instancetype)sickerMessageScrollView {

    YZSickerMessageScrollView *scrollView = [[YZSickerMessageScrollView alloc] init];
    
    [scrollView prepareUI];
    [scrollView setSubviewsFrame];
    
    
    return scrollView;
}

- (void)prepareUI {

    [self addSubview:self.sickerView];
    [self addSubview:self.doctorView];
    [self addSubview:self.sickView];
}

- (void)setSubviewsFrame {

    [self.sickerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.trailing.equalTo(self);
        make.height.mas_equalTo(100);
        make.width.equalTo(self);
        
    }];
    
    [self.doctorView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.sickerView.mas_bottom);
        make.leading.trailing.equalTo(self);
        self.oldConstraint = make.height.mas_equalTo(100);
    }];
    
    [self.sickView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.doctorView.mas_bottom);
        make.leading.trailing.equalTo(self);
        make.bottom.equalTo(self);
        make.height.equalTo(self);
    }];
}

- (YZSickerMessageView *)sickerView {
    if (!_sickerView) {
        _sickerView = [YZSickerMessageView sickerMessageView];
    }
    return _sickerView;
}

bool isClick=true;

- (YZDoctorConditionView *)doctorView {
    if (!_doctorView) {
        _doctorView = [YZDoctorConditionView doctorConditionView];
        __weak __typeof(self)weakSelf = self;
        _doctorView.opneButtonDidClickBlock = ^ {
            [weakSelf.doctorView mas_makeConstraints:^(MASConstraintMaker *make) {
                isClick = !isClick;
                [weakSelf.oldConstraint uninstall];
                if (isClick) {
                    weakSelf.oldConstraint = make.height.mas_equalTo(100);
                }else {
                    weakSelf.oldConstraint = make.height.mas_equalTo(30);
                }
            }];
        };
    }
    return _doctorView;
}

- (YZSickDetailsView *)sickView {
    if (!_sickView) {
        _sickView = [YZSickDetailsView sickDetailsView];
        __weak __typeof(self)weakSelf = self;
        _sickView.changeButtonDidClickBlock = ^ {
            weakSelf.changeButtonOfSickViewBeDidClickBlock();
        };
    }
    return _sickView;
}

- (UIView *)testview {
    if (!_testview) {
        _testview = [[UIView alloc] init];
    }
    return _testview;
}

@end
